import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @Authther: mrwu
 * @date:2021/3/4-03
 * @Description:PACKAGE_NAME
 */
public class Egxample1 implements Hello{
//    InvocationHandler

    @Override
    public void morning(String name) {
        System.out.println(name);
    }

//    public static void main(String[] args) {
//        Egxample1 egxample1 = new Egxample1();
//        egxample1.morning("huisheng");
//    }
}


interface Hello {
   void morning(String name);
}
class Main1{
    public static void main(String[] args) {
    InvocationHandler handler = new InvocationHandler() {
        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            System.out.println(method);
            if (method.getName().equals("morning")){
                System.out.println(args[0]);
            }
            return null;
        }
    };

    Hello hello =(Hello) Proxy.newProxyInstance(
            Hello.class.getClassLoader(),//传入classloader
            new Class[]{Hello.class},//传入要实现的接口
            handler);//传入处理调用方法
    hello.morning("huisheng");

    }
}
